﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Runtime.InteropServices;
using Bling.DSL;
using Bling.DataBinding;
using Bling.Shapes;
using Bling.Geom;
using Bling.Animation;
using Bling.WPF;

namespace Bling.Examples {

  class RingElement : Canvas {

    public Rectangle HoleRect = new Rectangle();

    public double RealDegree;

    public RingElement() {

    }

  }


  class RingEffectCanvas : Canvas {

    private static readonly TypedDependencyProperty<RingEffectCanvas, Point> RingCenterProperty = "RingCenter".RegisterDp<RingEffectCanvas, Point>();

    private static readonly TypedDependencyProperty<RingEffectCanvas, double> RingInnerRadiusProperty = "RingInnerRadius".RegisterDp<RingEffectCanvas, double>();
    private static readonly TypedDependencyProperty<RingEffectCanvas, double> RingOuterRadiusProperty = "RingOuterRadius".RegisterDp<RingEffectCanvas, double>();

    private static readonly TypedDependencyProperty<RingEffectCanvas, Point> HoleCenterProperty = "HoleCenter".RegisterDp<RingEffectCanvas, Point>();
    private static readonly TypedDependencyProperty<RingEffectCanvas, double> HoleRadiusProperty = "RingRadiusSize".RegisterDp<RingEffectCanvas, double>();

    //
    // in ringList, the smaller value of zindex is in the first, always increase from first to last, 
    // and the angle is always decrease from frist to last.
    //
    private List<RingElement> ringList = new List<RingElement>();

    public readonly VisualBrush RingBrush = new VisualBrush() {
      //AutoLayoutContent = false,
      Stretch = Stretch.Fill,
      TileMode = TileMode.None,
      ViewboxUnits = BrushMappingMode.RelativeToBoundingBox, Viewbox = new Rect(0, 0, 1, 1),
      ViewportUnits = BrushMappingMode.RelativeToBoundingBox, Viewport = new Rect(0, 0, 1, 1)

    };


    private Func<RingElement, BrushDSL, PointDSL, ColorDSL> ringEffect;

#if false
    public RingEffectCanvas() {
      RingInnerRadiusProperty.Dsl(this).Bind = 70.0;
      RingOuterRadiusProperty.Dsl(this).Bind = 100.0;

      HoleCenterProperty.Dsl(this).Bind = new Point(50, 100);

      HoleRadiusProperty.Dsl(this).Bind = 15.0;
      RingCenterProperty.Dsl(this).Bind = this.Dsl().Centersize;


      this.Size().Value = (RingOuterRadiusProperty.Signal(this) * 2).Point(RingOuterRadiusProperty.Signal(this) * 2).Value;

      RingBrush.Visual = this;
#endif
  }

}
